package com.tianqu.tms.www.bid.controller;

import java.io.File;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import org.apache.struts.upload.FormFile;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsController;
import com.tianqu.tms.core.base.TxController;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.exception.TransactionException;
import com.tianqu.tms.core.security.TmsUserProfile;
import com.tianqu.tms.core.util.CopyFile;
import com.tianqu.tms.core.util.DateUtil;
import com.tianqu.tms.core.util.ImageUtils;
import com.tianqu.tms.core.util.Registry;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.core.webservice.weichat.api.MobileMessage;
import com.tianqu.tms.core.webservice.weichat.api.PullingExecutor;
import com.tianqu.tms.core.webservice.weichat.api.rpc.transferserviceI.TransferDataSyn40000Bo;
import com.tianqu.tms.entity.AucCarInfo;
import com.tianqu.tms.entity.AucManagement;
import com.tianqu.tms.entity.CarImage;
import com.tianqu.tms.entity.Codes;
import com.tianqu.tms.entity.Sequence;
import com.tianqu.tms.www.bid.viewhelper.BidCarSerchInputViewHelper;

public class BidCarSerchAddResultController extends TmsController {
	private Logger logger = Logger.getLogger(BidCarSerchAddResultController.class);
	private String Serial = null;
	private int manaMaxId = 0;
	private int userId = 0;
	private int cId = 0;
	private String sysPath = null;

	@Override
	public void execute(UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		TmsUserProfile file = uc.getUserProfile();
		this.userId = file.getUniqueId();
		TxController controller = TxController.getTxController();
		BidCarSerchInputViewHelper vie = (BidCarSerchInputViewHelper) uc
				.getAttribute(TmsConstants.VIEWHELP);

		// 添加事务提交异常捕获
		try {
			controller.begin();

			sysPath = (String) uc.getAttribute("sysPath");
			Codes codes = Codes.getInstance();
			AucCarInfo aucCar = AucCarInfo.getInstance();
			AucCarInfo aucCarOld = AucCarInfo.getInstance();
			
			String vin = (String) uc.getParameter("vin");
			String id = (String) uc.getParameter("id");
			String modifyFlg ="";
			
			if(StringUtil.isNullOrBlank(vie.getSerial()))
			{
				modifyFlg = "false";
				Sequence sequence = Sequence.getInstance();
				// 获取车辆ID
				Serial = sequence.getSerial(2);
				aucCar = getAucCar(vie, Serial, codes);
				// 插入车辆基本信息表
				cId = aucCar.insertAucCar(aucCar);
			}
			else
			{
				modifyFlg = "true";
				Serial = vie.getSerial();
				if (!StringUtil.isNullOrBlank(String.valueOf(uc.getAttribute("modifyFlg")))
						&& "1".equals(uc.getAttribute("modifyFlg"))
						&& !StringUtil.isNullOrBlank(vin)) {
					// 车架号修改
					vie.setVin(vin);
				}

				aucCarOld = aucCarOld.getaucCarBase(Serial);
				
				aucCar = getAucCar(vie, Serial, codes);
				// 更新车辆基本信息表
				aucCar.updateCar(aucCar);
				
				aucCar = aucCar.getaucCarBase(Serial);
				cId = aucCar.getId();
			}

			AucManagement aucManager = AucManagement.getInstance();
			if (!StringUtil.isNullOrBlank(String.valueOf(uc.getAttribute("modifyFlg")))
					&& "1".equals(uc.getAttribute("modifyFlg"))
					&& !StringUtil.isNullOrBlank(id)) {
				aucManager = getAucManager(vie, Serial, 1);
				manaMaxId = Integer.valueOf(id);
				aucManager.setId(manaMaxId);
				// 更新交易管理表
				aucManager.updateAucManage(aucManager);
			}
			else
			{
				aucManager = getAucManager(vie, Serial, 0);
				// 插入交易管理表
				aucManager.insertAucMeager(aucManager);
				// 交易管理表最新ID取得
				manaMaxId = aucManager.getManaMaxId();
			}

			CarImage carImg = CarImage.getInstance();
			/**
			 * 插入图片信息
			 */
			carImg.insertCarImages(getcarInage(vie));

			controller.commit();
			
			// 【TMS】参拍登记/车辆寻价(今日) 的信息修改=》【车代办】同步
			aucCarAddTransfer(vie, modifyFlg, aucCarOld);

		} catch (Exception e) {
			try {
				controller.rollback();
			} catch (TransactionException e1) {
				throw new TmsException(TmsException.DB_TXCRROR, e1);
			}
			// 系统异常
			if (e instanceof TmsException) {
				throw e;
			}
			throw new TmsException(TmsException.DB_TXCRROR, e);
		}
	}

	/**
	 * 车辆信息
	 * 
	 * @param view
	 * @return
	 */
	private AucCarInfo getAucCar(BidCarSerchInputViewHelper view, String Serial,
			Codes codes) {
		AucCarInfo auc = new AucCarInfo();
		auc.setCarName(view.getCarName());
		auc.setSerial(Serial);
		auc.setCarOwner(view.getCarOwner());
		auc.setCarDetectId(view.getCarDetectId());
		auc.setVin(view.getVin());
		auc.setLicensePlate(view.getLicensePlate());
		auc.setPrice(StringUtil.getint(view.getPrice()));
		auc.setMileage(StringUtil.getint(view.getMileage()));
		auc.setRegDate(view.getRegDate());
		auc.setYearCarefulPeriod(view.getYearCarefulPeriod());
		auc.setJqx(view.getJqx());
		auc.setContactPerson(view.getContactPerson());
		auc.setContactPhone(view.getContactPhone());
		auc.setCarOwnerIdCardNo(view.getCarOwnerIdCardNo());
		auc.setVendorId(view.getVendorId());
		auc.setBrandId(view.getBrandId());
		auc.setCarStyleId(view.getCarStyleId());
		auc.setOwnerPhone(view.getOwnerPhone());
		auc.setOwnerAddress(view.getOwnerAddress());
		auc.setUpdateTime(view.getUpdateTime());
		auc.setUpdateUser(userId);
		auc.setInsertTime(view.getInsertTime());
		// 颜色
		auc.setColor(Integer.valueOf(view.getColor()));
		// 车主类别
		auc.setOwnerType(Integer.valueOf(view.getOwnerType()));
		auc.setOwnerSex(view.getOwnerSex());
		auc.setOwnerBirthday(view.getOwnerBirthday());
		auc.setPhoto1(view.getImages1());
		auc.setPhoto2(view.getImages2());
		auc.setPhoto3(view.getImages3());
		auc.setPhoto4(view.getImages4());
		auc.setPhoto5(view.getImages5());
		auc.setPhoto6(view.getImages6());
		auc.setPhoto7(view.getImages7());
		auc.setPhoto8(view.getImages8());
		auc.setPhoto9(view.getImages9());
		auc.setPhoto10(view.getImages10());
		auc.setPhoto11(view.getImages11());
		auc.setPhoto12(view.getImages12());
		auc.setPhoto13(view.getImages13());
		auc.setPhoto14(view.getImages14());
		auc.setPhoto15(view.getImages15());
		auc.setPhoto16(view.getImages16());
		auc.setPhoto17(view.getImages17());
		auc.setPhoto18(view.getImages18());
		auc.setPhoto19(view.getImages19());
		auc.setPhoto20(view.getImages20());
		auc.setPhoto21(view.getImages21());
		auc.setPhoto22(view.getImages22());// 图片从8张增加到20张  modify by mufeiyu

		return auc;
	}

	/**
	 * 竞价信息
	 * 
	 * @param view
	 * @return
	 */
	private AucManagement getAucManager(BidCarSerchInputViewHelper view,
			String Serial, int modifyFlg) {
		AucManagement aucManager = new AucManagement();
		aucManager.setSerial(Serial);
		// 登记
		if(modifyFlg == 0)
		{
			// 竞价开始时间，登记时候自动变成发布时间+2分钟 modify by mufeiyu
			String dataFormat = DateUtil.getTimeByTimeStamp1(new Timestamp(System.currentTimeMillis() + 120000));
			aucManager.setStartTime(DateUtil.getStringToTimeStamp(dataFormat.substring(11, 16)));
			view.setStartTime(String.valueOf(dataFormat.substring(11, 16)));
		}
		// 修改
		else if(modifyFlg == 1)
		{
			aucManager.setStartTime(DateUtil.getStringToTimeStamp(view.getStartTime()));
		}
		aucManager.setAuctionDeadline(StringUtil.getint(view
				.getAuctionDeadline()));
		aucManager.setBidType(1);
		aucManager.setBidStatus(1);

		return aucManager;
	}

	/**
	 * 图片信息
	 * 
	 * @param view
	 * @return
	 */
	private List<CarImage> getcarInage(BidCarSerchInputViewHelper view) {
		List<CarImage> list = new ArrayList<CarImage>();
		if (!StringUtil.isNullOrBlank(view.getImages1())) {
			list.add(carImage(1,view.getImages1()));
			imageUpLoad(view.getImages1(), imagePath(1,view.getImages1()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages2())) {
			list.add(carImage(2,view.getImages2()));
			imageUpLoad(view.getImages2(), imagePath(2,view.getImages2()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages3())) {
			list.add(carImage(3,view.getImages3()));
			imageUpLoad(view.getImages3(), imagePath(3,view.getImages3()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages4())) {
			list.add(carImage(4,view.getImages4()));
			imageUpLoad(view.getImages4(), imagePath(4,view.getImages4()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages5())) {
			list.add(carImage(5,view.getImages5()));
			imageUpLoad(view.getImages5(), imagePath(5,view.getImages5()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages6())) {
			list.add(carImage(6,view.getImages6()));
			imageUpLoad(view.getImages6(), imagePath(6,view.getImages6()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages7())) {
			list.add(carImage(7,view.getImages7()));
			imageUpLoad(view.getImages7(), imagePath(7,view.getImages7()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages8())) {
			list.add(carImage(8,view.getImages8()));
			imageUpLoad(view.getImages8(), imagePath(8,view.getImages8()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages9())) {
			list.add(carImage(9,view.getImages9()));
			imageUpLoad(view.getImages9(), imagePath(9,view.getImages9()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages10())) {
			list.add(carImage(10,view.getImages10()));
			imageUpLoad(view.getImages10(), imagePath(10,view.getImages10()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages11())) {
			list.add(carImage(11,view.getImages11()));
			imageUpLoad(view.getImages11(), imagePath(11,view.getImages11()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages12())) {
			list.add(carImage(12,view.getImages12()));
			imageUpLoad(view.getImages12(), imagePath(12,view.getImages12()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages13())) {
			list.add(carImage(13,view.getImages13()));
			imageUpLoad(view.getImages13(), imagePath(13,view.getImages13()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages14())) {
			list.add(carImage(14,view.getImages14()));
			imageUpLoad(view.getImages14(), imagePath(14,view.getImages14()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages15())) {
			list.add(carImage(15,view.getImages15()));
			imageUpLoad(view.getImages15(), imagePath(15,view.getImages15()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages16())) {
			list.add(carImage(16,view.getImages16()));
			imageUpLoad(view.getImages16(), imagePath(16,view.getImages16()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages17())) {
			list.add(carImage(17,view.getImages17()));
			imageUpLoad(view.getImages17(), imagePath(17,view.getImages17()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages18())) {
			list.add(carImage(18,view.getImages18()));
			imageUpLoad(view.getImages18(), imagePath(18,view.getImages18()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages19())) {
			list.add(carImage(19,view.getImages19()));
			imageUpLoad(view.getImages19(), imagePath(19,view.getImages19()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages20())) {
			list.add(carImage(20,view.getImages20()));
			imageUpLoad(view.getImages20(), imagePath(20,view.getImages20()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages21())) {
			list.add(carImage(21,view.getImages21()));
			imageUpLoad(view.getImages21(), imagePath(21,view.getImages21()));
		}
		if (!StringUtil.isNullOrBlank(view.getImages22())) {
			list.add(carImage(22,view.getImages22()));
			imageUpLoad(view.getImages22(), imagePath(22,view.getImages22()));
		}// 图片从8张增加到20张  modify by mufeiyu

		return list;
	}

	/**
	 * 图片类
	 * 
	 * @param value
	 * @return
	 */
	private CarImage carImage(int key,String imgPath) {
		CarImage carImage = new CarImage();
		carImage.setcId(cId);
		carImage.setImgKey(String.valueOf(key));
		carImage.setImgPath(ImageUtils.getImageUrl( Registry.getConfig(TmsConstants.UPLOAD_AUCTION_IMAGE_PATCH_KEY) + Serial + "/" + imagePath(key,imgPath)));
		carImage.setImgSrc(3);
		carImage.setImgType(String.valueOf(1));
		return carImage;
	}

	/**
	 * 将图片上传到服务器
	 */
	private void imageUpLoad(String Path, String ImageName) {

		Path = Path.replace(ImageUtils.getImageUrl(Registry.getConfig(TmsConstants.UPLOAD_AUCTION_IMAGE_PATCH_TMP_KEY)), "");
		File infoFile = new File(ImageUtils.getImageDirectoryPath(Registry.getConfig(TmsConstants.UPLOAD_AUCTION_IMAGE_PATCH_TMP_KEY))+Path);
		File outFile = new File(ImageUtils.getImageDirectoryPath(Registry.getConfig(TmsConstants.UPLOAD_AUCTION_IMAGE_PATCH_KEY) + Serial + "/") + ImageName);

		CopyFile.copy(infoFile, outFile);
	}

	/**
	 * 图片名称
	 * 
	 * @param Key
	 * @return
	 */
	private String imagePath(int Key,String imgPath) {
		String a = "1";
		String k = String.valueOf(Key);
		String t = "3";
		return this.Serial + a + k + t + getImgFormat(imgPath);
	}
	/**
	 * 图片后缀
	 * 
	 * @param imgPath
	 * @return
	 */
	public String getImgFormat(String imgPath) {
		int i = 0;
		if(imgPath.length()==0)return "";
		while (i != -1) {
			// 找到上传文件的类型的位置，这个地方的是'.'
			i = imgPath.indexOf(".");
			/* 截取上传文件的后缀名,此时得到了文件的类型 */
			imgPath = imgPath.substring(i+1).toLowerCase();
		}
		imgPath = "." + imgPath;
		return imgPath;
	}

	/**
	 * 【TMS】参拍登记/车辆寻价(今日) 的信息修改=》【车代办】同步
	 * 
	 * @param Key
	 * @return
	 */
	private void aucCarAddTransfer(BidCarSerchInputViewHelper view, String modifyFlg, AucCarInfo aucCarOld) {
		
		//if(!StringUtil.isNullOrBlank(viewhelper.getmLicensePlate())){

		MobileMessage message = new MobileMessage();
		message.putValue("Serial", view.getSerial());
		message.setMessage("【TMS】参拍登记/车辆寻价(今日) 的信息修改==>【车代办】同步,Serial为#Serial#");
		String imagePath = ImageUtils.getImageDirectoryPath(Registry.getConfig(TmsConstants.UPLOAD_AUCTION_IMAGE_PATCH_TMP_KEY));
				
		String photo1 = !StringUtil.isNullOrBlank(view.getImages1())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages1())):"";
		String photo2 = !StringUtil.isNullOrBlank(view.getImages2())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages2())):"";
		String photo3 = !StringUtil.isNullOrBlank(view.getImages3())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages3())):"";
		String photo4 = !StringUtil.isNullOrBlank(view.getImages4())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages4())):"";
		String photo5 = !StringUtil.isNullOrBlank(view.getImages5())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages5())):"";
		String photo6 = !StringUtil.isNullOrBlank(view.getImages6())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages6())):"";
		String photo7 = !StringUtil.isNullOrBlank(view.getImages7())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages7())):"";
		String photo8 = !StringUtil.isNullOrBlank(view.getImages8())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages8())):"";
		String photo9 = !StringUtil.isNullOrBlank(view.getImages9())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages9())):"";
		String photo10 = !StringUtil.isNullOrBlank(view.getImages10())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages10())):"";
		String photo11 = !StringUtil.isNullOrBlank(view.getImages11())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages11())):"";
		String photo12 = !StringUtil.isNullOrBlank(view.getImages12())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages12())):"";
		String photo13 = !StringUtil.isNullOrBlank(view.getImages13())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages13())):"";
		String photo14 = !StringUtil.isNullOrBlank(view.getImages14())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages14())):"";
		String photo15 = !StringUtil.isNullOrBlank(view.getImages15())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages15())):"";
		String photo16 = !StringUtil.isNullOrBlank(view.getImages16())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages16())):"";
		String photo17 = !StringUtil.isNullOrBlank(view.getImages17())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages17())):"";
		String photo18 = !StringUtil.isNullOrBlank(view.getImages18())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages18())):"";
		String photo19 = !StringUtil.isNullOrBlank(view.getImages19())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages19())):"";
		String photo20 = !StringUtil.isNullOrBlank(view.getImages20())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages20())):"";
		String photo21 = !StringUtil.isNullOrBlank(view.getImages21())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages21())):"";
		String photo22 = !StringUtil.isNullOrBlank(view.getImages22())?ImageUtils.transPicToStr(imagePath + getImageName(view.getImages22())):"";
		
		if ("true".equals(modifyFlg)) {
			
			if (view.getImages1().equals(aucCarOld.getPhoto1())) {
				photo1 = "";
			}
			
			if (view.getImages2().equals(aucCarOld.getPhoto2())) {
				photo2 = "";
			}
			
			if (view.getImages3().equals(aucCarOld.getPhoto3())) {
				photo3 = "";
			}
			
			if (view.getImages4().equals(aucCarOld.getPhoto4())) {
				photo4 = "";
			}
			
			if (view.getImages5().equals(aucCarOld.getPhoto5())) {
				photo5 = "";
			}
			
			if (view.getImages6().equals(aucCarOld.getPhoto6())) {
				photo6 = "";
			}
			
			if (view.getImages7().equals(aucCarOld.getPhoto7())) {
				photo7 = "";
			}
			
			if (view.getImages8().equals(aucCarOld.getPhoto8())) {
				photo8 = "";
			}
			
			if (view.getImages9().equals(aucCarOld.getPhoto9())) {
				photo9 = "";
			}
			
			if (view.getImages10().equals(aucCarOld.getPhoto10())) {
				photo10 = "";
			}
			
			if (view.getImages11().equals(aucCarOld.getPhoto11())) {
				photo11 = "";
			}
			
			if (view.getImages12().equals(aucCarOld.getPhoto12())) {
				photo12 = "";
			}
			
			if (view.getImages13().equals(aucCarOld.getPhoto13())) {
				photo13 = "";
			}
			
			if (view.getImages14().equals(aucCarOld.getPhoto14())) {
				photo14 = "";
			}
			
			if (view.getImages15().equals(aucCarOld.getPhoto15())) {
				photo15 = "";
			}
			
			if (view.getImages16().equals(aucCarOld.getPhoto16())) {
				photo16 = "";
			}
			
			if (view.getImages17().equals(aucCarOld.getPhoto17())) {
				photo17 = "";
			}
			
			if (view.getImages18().equals(aucCarOld.getPhoto18())) {
				photo18 = "";
			}
			
			if (view.getImages19().equals(aucCarOld.getPhoto19())) {
				photo19 = "";
			}
			
			if (view.getImages20().equals(aucCarOld.getPhoto20())) {
				photo20 = "";
			}
			
			if (view.getImages21().equals(aucCarOld.getPhoto21())) {
				photo21 = "";
			}
			
			if (view.getImages22().equals(aucCarOld.getPhoto22())) {
				photo22 = "";
			}
		}
				
		TransferDataSyn40000Bo api = new TransferDataSyn40000Bo();
		api.setMobileMessage(message);
	
		api.setSerial(Serial);
		api.setId(String.valueOf(manaMaxId));
		api.setLicensePlate(view.getLicensePlate());
		api.setVin(view.getVin());
		api.setMileage(view.getMileage());
		api.setVendorId(view.getVendorId());
		api.setBrandId(view.getBrandId());
		api.setCarStyleId(view.getCarStyleId());
		api.setCarName(view.getCarName());
		api.setColor(view.getColor());
		api.setPrice(view.getPrice());
		api.setRegDate(view.getRegDate());
		api.setJqx(view.getJqx());
		api.setYearCarefulPeriod(view.getYearCarefulPeriod());
		api.setContactPerson(view.getContactPerson());
		api.setContactPhone(view.getContactPhone());
		api.setCarOwner(view.getCarOwner());
		api.setOwnerType(view.getOwnerType());
		api.setCarOwnerIdCardNo(view.getCarOwnerIdCardNo());
		api.setSex(view.getOwnerSex());
		api.setOwnerPhone(view.getOwnerPhone());
		api.setOwnerAddress(view.getOwnerAddress());
		api.setBirthday(view.getOwnerBirthday());
		api.setPhoto_9(!StringUtil.isNullOrBlank(photo9)?photo9 + getImgFormat(view.getImages9()):"");
		api.setPhoto_10(!StringUtil.isNullOrBlank(photo10)?photo10 + getImgFormat(view.getImages10()):"");
		api.setPhoto_1(!StringUtil.isNullOrBlank(photo1)?photo1 + getImgFormat(view.getImages1()):"");
		api.setPhoto_2(!StringUtil.isNullOrBlank(photo2)?photo2 + getImgFormat(view.getImages2()):"");
		api.setPhoto_3(!StringUtil.isNullOrBlank(photo3)?photo3 + getImgFormat(view.getImages3()):"");
		api.setPhoto_4(!StringUtil.isNullOrBlank(photo4)?photo4 + getImgFormat(view.getImages4()):"");
		api.setPhoto_5(!StringUtil.isNullOrBlank(photo5)?photo5 + getImgFormat(view.getImages5()):"");
		api.setPhoto_6(!StringUtil.isNullOrBlank(photo6)?photo6 + getImgFormat(view.getImages6()):"");
		api.setPhoto_7(!StringUtil.isNullOrBlank(photo7)?photo7 + getImgFormat(view.getImages7()):"");
		api.setPhoto_8(!StringUtil.isNullOrBlank(photo8)?photo8 + getImgFormat(view.getImages8()):"");
		api.setPhoto_11(!StringUtil.isNullOrBlank(photo11)?photo11 + getImgFormat(view.getImages11()):"");
		api.setPhoto_12(!StringUtil.isNullOrBlank(photo12)?photo12 + getImgFormat(view.getImages12()):"");
		api.setPhoto_13(!StringUtil.isNullOrBlank(photo13)?photo13 + getImgFormat(view.getImages13()):"");
		api.setPhoto_14(!StringUtil.isNullOrBlank(photo14)?photo14 + getImgFormat(view.getImages14()):"");
		api.setPhoto_15(!StringUtil.isNullOrBlank(photo15)?photo15 + getImgFormat(view.getImages15()):"");
		api.setPhoto_16(!StringUtil.isNullOrBlank(photo16)?photo16 + getImgFormat(view.getImages16()):"");
		api.setPhoto_17(!StringUtil.isNullOrBlank(photo17)?photo17 + getImgFormat(view.getImages17()):"");
		api.setPhoto_18(!StringUtil.isNullOrBlank(photo18)?photo18 + getImgFormat(view.getImages18()):"");
		api.setPhoto_19(!StringUtil.isNullOrBlank(photo19)?photo19 + getImgFormat(view.getImages19()):"");
		api.setPhoto_20(!StringUtil.isNullOrBlank(photo20)?photo20 + getImgFormat(view.getImages20()):"");
		api.setPhoto_21(!StringUtil.isNullOrBlank(photo21)?photo21 + getImgFormat(view.getImages21()):"");
		api.setPhoto_22(!StringUtil.isNullOrBlank(photo22)?photo22 + getImgFormat(view.getImages22()):"");
		api.setBidType("1");// 寻价模式
		api.setStartTime(String.valueOf(DateUtil.getStringToTimeStamp(view
				.getStartTime())));
		api.setAuctionDeadline(view.getAuctionDeadline());

		PullingExecutor.getInstance().submit(api);
	//}
	}

	/**
	 * 图片名称的取得
	 * 
	 * @param imagePath 图片路径
	 * @return
	 */
	private String getImageName(String imagePath){
		if(StringUtil.isNullOrBlank(imagePath)) return "";
		return imagePath.substring(imagePath.lastIndexOf("/")+1);
	}
}

